//可实现的业务功能
#pragma once
#include <iostream>
#include <string>
#include <memory>
#include "Protocol.hpp"



struct NetCal
{
	static std::shared_ptr<Response> Calculator(std::shared_ptr<Request> req)
	{
		shared_ptr<Response> resp=make_shared<Response>();
	switch(req->Oper())
	{
	case '+':
            resp->_result = req->X() + req->Y();
            break;
        case '-':
            resp->_result = req->X() - req->Y();
            break;
        case '*':
            resp->_result = req->X() * req->Y();
            break;
        case '/':
        {
            if (req->Y() == 0)
            {
                resp->_code = 1;
                resp->_desc = "div zero";
            }
            else
            {
                resp->_result = req->X() / req->Y();
            }
        }
        break;
        case '%':
        {
            if (req->Y() == 0)
            {
                resp->_code = 2;
                resp->_desc = "mod zero";
            }
            else
            {
                resp->_result = req->X() % req->Y();
            }
        }
        break;
        default:
        {
            resp->_code = 3;
            resp->_desc = "illegal operation";
        }
        break;
        };
	return resp;
	

	};
};

